class Solution(object):
    def averageWaitingTime(self, customers):
        time = 0
        n = len(customers)
        ans = []
        for a, w in customers:
            time = max(time, a)
            time += w
            ans.append(time - a)
        return sum(ans) / n